//
//  CZQCoachMoveDetailTCell.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/26.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "CZQCoachMoveDetailTCell.h"
@implementation CZQCoachMoveDetailHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
//        self.backgroundColor = CSWhiteColor;
        
        /**
         背景图片
         */
        UIImageView *bgView = [UIImageView new];
        bgView.image = [UIImage imageNamed:@"img_bg"];
        [self addSubview:bgView];
        self.bgView = bgView;

        
        /**
         头像图片
         */
        
        UIButton *iconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [iconBtn setImage:PlaceHold forState:UIControlStateNormal];
        iconBtn.layer.cornerRadius = 30;
        iconBtn.clipsToBounds = YES;
        [self addSubview:iconBtn];
        self.iconBtn = iconBtn;
        
    
        
        /**
         教练名
         */
        UILabel *nameLable = [UILabel new];
        nameLable.text = @"陈志强";
        nameLable.font = BigFont;
        nameLable.textColor = BlackColor;
        [self addSubview:nameLable];
        self.nameLable = nameLable;
        
        
        
        /**
         内容
         */
        UILabel *titleLable = [UILabel new];
        titleLable.text = @"高效冲击，完美腹部";
        titleLable.font = MidBigFont;
        titleLable.textColor = GrakColor;
        [self addSubview:titleLable];
        self.titleLable = titleLable;

        
        /**
         动态
         */
        UILabel *moveLable = [UILabel new];
        moveLable.text = @"动态";
        moveLable.font = MidBigFont;
        moveLable.textColor = GrakColor;
        moveLable.textAlignment = NSTextAlignmentCenter;
        [self addSubview:moveLable];
        self.moveLable = moveLable;

        
        /**
         动态个数
         */
        UILabel *moveCountLable = [UILabel new];
        moveCountLable.text = @"0";
        moveCountLable.font = MidBigFont;
        moveCountLable.textAlignment = NSTextAlignmentCenter;
        moveCountLable.textColor = BlackColor;
        [self addSubview:moveCountLable];
        self.moveCountLable = moveCountLable;

        
        /**
         粉丝
         */
        UILabel *likeLable = [UILabel new];
        likeLable.text = @"粉丝";
        likeLable.font = MidBigFont;
        likeLable.textColor = GrakColor;
        likeLable.textAlignment = NSTextAlignmentCenter;
        [self addSubview:likeLable];
        self.likeLable = likeLable;

        
        /**
         粉丝个数
         */
        UILabel *likeCountLable = [UILabel new];
        likeCountLable.text = @"0";
        likeCountLable.font = MidBigFont;
        likeCountLable.textColor = BlackColor;
        likeCountLable.textAlignment = NSTextAlignmentCenter;
        [self addSubview:likeCountLable];
        self.likeCountLable = likeCountLable;

        
        /**
         学员
         */
        UILabel *studyLable = [UILabel new];
        studyLable.text = @"学员";
        studyLable.font = MidBigFont;
        studyLable.textColor = GrakColor;
        studyLable.textAlignment = NSTextAlignmentCenter;
        [self addSubview:studyLable];
        self.studyLable = studyLable;

        
        /**
         学员个数
         */
        UILabel *studyCountLable = [UILabel new];
        studyCountLable.text = @"0";
        studyCountLable.font = MidBigFont;
        studyCountLable.textAlignment = NSTextAlignmentCenter;
        studyCountLable.textColor = BlackColor;
        [self addSubview:studyCountLable];
        self.studyCountLable = studyCountLable;

        
        /**
         关注
         */
        UIButton *attentionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        attentionBtn.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
        attentionBtn.layer.cornerRadius = 15;
        attentionBtn.clipsToBounds = YES;
        [attentionBtn setTitle:@"＋关注"];
        [attentionBtn setTitle:@"已关注" forState:UIControlStateSelected];
        attentionBtn.backgroundColor = ButtonBackGroundColor;
        [attentionBtn setTitleColor:BlackColor];
        attentionBtn.titleLabel.font = MidFont;
        [self addSubview:attentionBtn];
        self.attentionBtn = attentionBtn;

        [self setConstraints];
    }
    return self;
}


-(void)setConstraints
{
    /**
     背景图片
     */
    [self.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.width.top.left.mas_equalTo(self);
        make.height.mas_equalTo(60);
        
    }];
    
    /**
     头像图片
     */
    [self.iconBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).offset(30);
        make.width.height.mas_equalTo(60);
        
    }];
    
    /**
     名字
     */
    [self.nameLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.iconBtn.mas_bottom).offset(10);
        
    }];
    
    /**
     内容
     */
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.nameLable.mas_bottom).offset(10);
        
    }];
    
    /**
     动态
     */
    [self.moveLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self);
        make.width.mas_equalTo(kScreenWidth/4);
        make.top.mas_equalTo(self.moveCountLable.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self).offset(-10);
    }];
    
    /**
     动态个数
     */
    [self.moveCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self);
        make.width.mas_equalTo(self.moveLable);
        make.top.mas_equalTo(self.titleLable.mas_bottom).offset(20);
        
    }];
    
    /**
     粉丝
     */
    [self.likeLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.moveLable.mas_right);
        make.width.mas_equalTo(self.moveLable);
        make.top.mas_equalTo(self.moveLable);
        
    }];
    
    /**
     粉丝个数
     */
    [self.likeCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.likeLable);
        make.width.mas_equalTo(self.moveLable);
        make.top.mas_equalTo(self.moveCountLable);
        
    }];
    
    /**
     学员
     */
    [self.studyLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.likeLable.mas_right);
        make.width.mas_equalTo(self.moveLable);
        make.top.mas_equalTo(self.moveLable);
        
    }];
    
    /**
     学员个数
     */
    [self.studyCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.likeCountLable.mas_right);
        make.width.mas_equalTo(self.moveLable);
        make.top.mas_equalTo(self.moveCountLable);
        
    }];
    
    /**
     关注
     */
    [self.attentionBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(-10);
        make.top.mas_equalTo(self.moveCountLable).offset(5);
        make.height.mas_equalTo(30);
        
    }];

    
}
@end
@implementation CZQCoachMoveDetailTCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        /**
         时间月
         */
        UILabel *monthLable = [UILabel new];
        monthLable.font = MidFont;
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]
                                              initWithString:@"02\n十二月"];
        
        [attrStr addAttribute:NSFontAttributeName value:
         [UIFont boldSystemFontOfSize:18.0f] range:NSMakeRange(0, 2)];
        
        
        monthLable.attributedText = attrStr;
        monthLable.textColor = GrakColor;
        monthLable.numberOfLines = 0;
        [self addSubview:monthLable];
        self.timeMonthLable = monthLable;
        
        /**
         时间小时
         */
        UILabel *timeHoursLable = [UILabel new];
        timeHoursLable.text = @"今天19；00·发布了动态";
        timeHoursLable.font = MidFont;
        timeHoursLable.textColor = GrakColor;
        [self addSubview:timeHoursLable];
        self.timeHoursLable = timeHoursLable;
        
        /**
         动态内容
         */
        UILabel *titleLable = [UILabel new];
        titleLable.text = @"今天发布了动态";
        titleLable.font = MidBigFont;
        titleLable.numberOfLines = 0;
        titleLable.textColor = BlackColor;
        [self addSubview:titleLable];
        self.titleLable = titleLable;
        
        /**
         图片
         */
        JGGView *jggView = [JGGView new];
        [self addSubview:jggView];
        self.jggView = jggView;
        
        
        //观看人数
        
        UILabel *seeLable = [UILabel new];
        seeLable.text = @"10人观看";
        seeLable.font = SmallFont;
        seeLable.textColor = GrakColor;
        [self addSubview:seeLable];
        self.seeLable = seeLable;
        
        
        //评论人数
        UIButton *talkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        talkBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 3, 3, 3);
        [talkBtn setImage:@"icon_comment"];
        [talkBtn setTitle:@"3 "];
        [talkBtn setTitleColor:GrakColor];
        talkBtn.titleLabel.font = SmallFont;
        [self addSubview:talkBtn];
        self.talkBtn = talkBtn;
        
        //关注人数
        UIButton *goodBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        goodBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 3, 3, 3);
        [goodBtn setImage:@"icon_fabulous"];
        [goodBtn setTitle:@"3 "];
        [goodBtn setTitleColor:GrakColor];
        goodBtn.titleLabel.font = SmallFont;
        [self addSubview:goodBtn];
        self.goodBtn = goodBtn;
        
        
        [self setConstraints];
        
        
    }
    return self;
}


-(void)setConstraints
{
    

    /**
     时间月
     */
    [self.timeMonthLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(self).offset(10);
        make.width.mas_equalTo(50);
    }];
    
    
    /**
     时间小时
     */
    [self.timeHoursLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(15);
        make.left.mas_equalTo(self).offset(65);
        
    }];
    
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.timeHoursLable.mas_bottom).offset(10);
        make.left.mas_equalTo(self.timeHoursLable);
        make.right.lessThanOrEqualTo(self).offset(-10);

//        make.bottom.mas_equalTo(self).offset(-50);

    }];

    // 不然在6/6plus上就不准确了
    self.titleLable.preferredMaxLayoutWidth = kScreenWidth - 75;
    
    //放图片面板
    
    [self.jggView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLable.mas_bottom).offset(5);
        make.left.mas_equalTo(self.timeHoursLable);
        make.bottom.mas_equalTo(self).offset(-40);
    }];

    ///布局九宫格
    [self.jggView JGGView:self.jggView DataSource:@[PlaceHold,PlaceHold,PlaceHold,PlaceHold,PlaceHold,PlaceHold,PlaceHold,PlaceHold] completeBlock:^(NSInteger index, NSArray *dataSource,NSIndexPath *indexpath) {



    }];


    //观看人数
    [self.seeLable mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.timeHoursLable);
        make.top.mas_equalTo(self.jggView.mas_bottom).offset(10);
        make.bottom.mas_equalTo(self).offset(-10);
        make.height.mas_equalTo(20);

    }];





    //评论人数
    [self.talkBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.centerY.mas_equalTo(self.seeLable);
        make.right.mas_equalTo(self.goodBtn.mas_left).offset(-10);
//        make.height.mas_equalTo(30);

    }];
    
    [self.talkBtn imageOnTheTitleLeftWithSpace:3];
//
//    //关注人数
    [self.goodBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.right.mas_equalTo(self).offset(-10);
        make.centerY.mas_equalTo(self.seeLable);
////        make.height.mas_equalTo(30);
//
//
    }];

    [self.goodBtn imageOnTheTitleLeftWithSpace:3];
    

}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
